package com.jianneng.jdg.model.homeactivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.com.jianneng.jdg.R;
import com.jianneng.jdg.model.adapter.DetailAdapter;
import com.jianneng.jdg.model.gallery.ReleaseListService;

public class DetailsActivity extends BaseActivity {
private ListView mListView;
private DetailAdapter mAdapter;
private LinearLayout mBack;
private FrameLayout mCommentSend;
private TextView mSend;
private EditText mEditTextComment;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_details);
		init();
		//模拟数据
		mAdapter = new DetailAdapter(this, ReleaseListService.getReleaseService(),mCommentSend);
		System.out.println(ReleaseListService.getReleaseService().size()+"qqqqqqqqq");
		mListView.setAdapter(mAdapter);
		mListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Toast.makeText(getApplicationContext(), position+"", 1).show();
			}
			
		});
		mBack.setOnClickListener(new MyOnClickListener());
		mSend.setOnClickListener(new MyOnClickListener());
	}
	public class MyOnClickListener implements OnClickListener{

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.details_back:
				Intent intent = new Intent(getApplicationContext(), MyReleaseActivity.class);
				startActivity(intent);
				finish();
				break;
			case R.id.detail_item_send:
				Editable text = mEditTextComment.getText();
				Toast.makeText(getApplicationContext(), text.toString(), 1).show();
				mCommentSend.setVisibility(View.GONE);
				break;

			default:
				break;
			}
			
		}
		
	}
	
	private void init() {
		mListView = (ListView) findViewById(R.id.comment_listview);
		mBack = (LinearLayout) findViewById(R.id.details_back);
		mCommentSend = (FrameLayout) findViewById(R.id.add_comment);
		mSend = (TextView) findViewById(R.id.detail_item_send);
		mEditTextComment = (EditText) findViewById(R.id.detail_item_comment);
		
	}

}
